﻿using System;
using System.Text;
using IAM.Interface.Model;
using IAM.Interface.Common.Context;
using IAM.Interface.Model.ENUM;
using IAM.Interface.DAL.Request;

namespace RequestLocalLibrary
{
    /// <summary>
    /// 请求端本地类库
    /// </summary>
    public class Business
    {
        IAM.Interface.DAL.Request.ACIMgnt acimgnt = new ACIMgnt();
        IAM.Interface.DAL.Request.DelegationMgnt delegationmgnt = new DelegationMgnt();
        IAM.Interface.DAL.Request.IdentityMgnt identitymgnt = new IdentityMgnt();
        IAM.Interface.DAL.Request.OrganizationMgnt organizationmgnt = new OrganizationMgnt();
        #region 人员权限管理成员方法
        /// <summary>
        /// 获取权限模型
        /// </summary>
        /// <returns>所有的权限模型</returns>
        public ACMMode GetACIModel(AppType apptype)
        {
            acimgnt.AppType = apptype;
            return acimgnt.GetACIModel();
        }
        /// <summary>
        /// 获取用户权限信息
        /// </summary>
        /// <param name="accountinfo">人员帐号信息</param>
        /// <returns>用户的权限信息</returns>
        public ACI GetUserACI(AccountInfo accountinfo, AppType apptype)
        {
            acimgnt.AppType = apptype;
            return acimgnt.GetUserACI(accountinfo);
        }
        /// <summary>
        /// 设置用户权限信息
        /// </summary>
        /// <param name="acisessions">用户的权限信息</param>
        /// <returns>设置后用户权限信息</returns>
        public ACI SetUserACI(ACI aci, AppType apptype)
        {
            acimgnt.AppType = apptype;
            return acimgnt.SetUserACI(aci);
        }
        #endregion
        #region 代理管理方法
        /// <summary>
        /// 获取可代理模块列表
        /// </summary>
        /// <returns>可以进行代理设置的模块列表</returns>
        public Modules GetModuleList(AppType apptype)
        {
            delegationmgnt.AppType = apptype;
            return delegationmgnt.GetModuleList();
        }
        /// <summary>
        /// 获取用户代理信息
        /// </summary>
        /// <param name="accountinfo">人员帐号信息</param>
        /// <returns>代理设置信息列表</returns>
        public AIDelegations GetDelegationInfo(AccountInfo accountinfo, AppType apptype)
        {
            delegationmgnt.AppType = apptype;
            return delegationmgnt.GetDelegationInfo(accountinfo);
        }
        /// <summary>
        /// 设置用户代理信息
        /// </summary>
        /// <param name="aidelegations">用户代理信息</param>
        /// <returns>设置后的用户代理信息</returns>
        public AIDelegations SetDelegationInfo(AIDelegations aidelegations, AppType apptype)
        {
            delegationmgnt.AppType = apptype;
            return delegationmgnt.SetDelegationInfo(aidelegations);
        }
        #endregion
        #region  人员信息管理成员方法
        /// <summary>
        /// 创建用户
        /// 1.实例化RequestContextModel对象
        /// 2.实例化请求端上下文控制对象
        /// 3.发送消息
        /// 4.接收消息
        /// 5.转换通用类的类型
        /// </summary>
        /// <param name="identity">人员身份信息</param>
        /// <returns>人员账号信息</returns>
        public virtual AccountInfo CreateIdentity(Identity identity, AppType apptype)
        {
            identitymgnt.AppType = apptype;
            return identitymgnt.CreateIdentity(identity);
        }
        /// <summary>
        /// 激活用户
        /// </summary>
        /// <param name="identity">人员身份信息</param>
        /// <returns>人员账号信息</returns>
        public virtual AccountInfo EnableIdentity(Identity identity, AppType apptype)
        {
            identitymgnt.AppType = apptype;
            return identitymgnt.EnableIdentity(identity);
        }
        /// <summary>
        /// 禁用用户
        /// </summary>
        /// <param name="identity">人员身份信息</param>
        /// <returns>人员账号信息</returns>
        public virtual AccountInfo DisableIdentity(Identity identity, AppType apptype)
        {
            identitymgnt.AppType = apptype;
            return identitymgnt.DisableIdentity(identity);
        }
        /// <summary>
        /// 删除用户
        /// </summary>
        /// <param name="identity">人员身份信息</param>
        /// <returns>人员账号信息</returns>
        public virtual AccountInfo DeleteIdentity(Identity identity, AppType apptype)
        {
            identitymgnt.AppType = apptype;
            return identitymgnt.DeleteIdentity(identity);

        }
        /// <summary>
        /// 更新用户信息
        /// </summary>
        /// <param name="identity">人员身份信息</param>
        /// <returns>人员账号信息</returns>
        public virtual AccountInfo UpdateIdentity(Identity identity, AppType apptype)
        {
            identitymgnt.AppType = apptype;
            return identitymgnt.UpdateIdentity(identity);
        }
        #endregion  成员方法
        #region 组织信息管理方法
        /// <summary>
        /// 组织信息更新
        /// </summary>
        /// <param name="organizeinfo">组织机构信息,包括机构基本信息和主管人员信息</param>
        /// <returns>成功/失败</returns>
        public bool UpdateOrganize(OrganizeInfo organizeinfo, AppType apptype)
        {
            organizationmgnt.AppType = apptype;
            return organizationmgnt.UpdateOrganize(organizeinfo);

        }
        /// <summary>
        /// 组织机构创立
        /// </summary>
        /// <param name="organizeinfo">组织机构信息,包括机构基本信息和主管人员信息</param>
        /// <returns>成功/失败</returns>
        public bool CreateOrganize(OrganizeInfo organizeinfo, AppType apptype)
        {
            organizationmgnt.AppType = apptype;
            return organizationmgnt.CreateOrganize(organizeinfo);
        }
        /// <summary>
        /// 组织结构删除（包括合并）
        /// </summary>
        /// <param name="organizedeleteparameter">组织结构删除 组织机构信息</param>
        /// <returns>成功/失败</returns>
        public bool DeleteOrganize(OrganizeDeleteParameter organizedeleteparameter, AppType apptype)
        {
            organizationmgnt.AppType = apptype;
            return organizationmgnt.DeleteOrganize(organizedeleteparameter);
        }
        #endregion
    }
}
